/////////////////////////////////////
// Procesador.java (clase principal)
/////////////////////////////////////
package pl.p03;

import java.io.*;

import antlr.collections.AST;
import antlr.ANTLRException;

public class Procesador {

  public static void main(String args[]) {
    try {
      if (args.length == 0) {
        InputStreamReader isr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(isr);
        String linea = br.readLine();
        while (!linea.equals("$")) {
          LexAnalyzer lexer = new LexAnalyzer(new StringReader(linea));
          SyntaxAnalyzer parser = new SyntaxAnalyzer(lexer);
          parser.start_kb();
          linea = br.readLine();
        }// while
      } else {
        FileInputStream fis = new FileInputStream("./res/io/" + args[0]);
        LexAnalyzer lexer = new LexAnalyzer(fis);
        SyntaxAnalyzer parser = new SyntaxAnalyzer(lexer);
        parser.start();
      }// if-else
    }// try

    catch (ANTLRException ae) {
      System.err.println(ae.getMessage());
      System.out.println();
    }// catch

    catch (IOException ioe) {
      System.err.println(ioe.getMessage());
    }// catch
  }// main

}// Procesador